<template>
    <view class="pub_search">
        <input class="input" type="text" :placeholder="placeholder" v-model="searchVal" :maxlength="maxLength">
        <div class="btn_text" @click="toSearch" v-if="btnType==1">{{ btnTxt }}</div>
        <div class="btn_icon icon-font-basic icon-b-search" @click="toSearch" v-if="btnType==2"></div>
    </view>
</template>

<script>
export default {
    props: {
        placeholder: {
            type: String,
            default: '',
        },
        btnType: {
            type: Number,
            default: 1,//1文字按钮 2图标按钮
        },
        btnTxt: {
            type: String,
            default: '搜索',
        },
        maxLength: {
            type: Number,
            default: 140,
        }
    },
    data() {
        return {
            searchVal: ''
        };
    },
    watch: {},
    methods: {
        toSearch() {
            this.$emit("click", {
                searchVal: this.searchVal
            })
        },
        clearVal() {
            this.searchVal = ''
        }
    },
};
</script>

<style lang="scss" scoped></style>
